input1='10 3'
input2='3 2 2 1 2 3 1 3 3 3'

[n,k]=list(map(int,input1.split()))
type_list=list(map(int,input2.split()))

data_list=[[]for i in range(k)]

for ind,type in enumerate(type_list):
    data_list[type-1].append(ind+1)

input_list=[]
output_list=[]
for data in data_list:
    input_data=data[0:(len(data)+1)//2]
    output_data=data[(len(data)+1)//2:]

    for i in input_data:
        input_list.append(i)
    for j in output_data:
        output_list.append(j)


print(data_list)
print(' '.join(map(str,input_list)))
print('\n')
print(' '.join(map(str,output_list)))
